package com.yiyi.util;

import com.yiyi.entity.Answer;
import com.yiyi.entity.Choice;
import com.yiyi.entity.Exam;
import com.yiyi.entity.Result;
import com.yiyi.vo.ResultVO;

import java.util.List;

/**
 * 打包VO工具类
 *
 * @author yiyi
 * @date 2021/6/1
 */
public class PackageVOUtil {

    /**
     * 组装考试结果
     *
     * @param result
     * @param exam
     * @param choiceList
     * @param answerList
     * @return
     * */
    public static ResultVO packageResultVO(Result result, Exam exam, List<Choice> choiceList, List<Answer> answerList) {
        ResultVO resultVO = new ResultVO();
        // 结果相关
        resultVO.setResultId(result.getResultId());
        resultVO.setResultGrade(result.getResultGrade());
        resultVO.setResultStatus(result.getResultStatus());
        resultVO.setExamId(result.getExamId());
        resultVO.setChoiceKey(TypeConverterUtil.stringToStringList(result.getChoiceKey()));
        resultVO.setChoiceGrade(TypeConverterUtil.stringToIntegerList(result.getChoiceGrade()));
        resultVO.setAnswerKey(TypeConverterUtil.stringToStringList(result.getAnswerKey()));
        resultVO.setAnswerGrade(TypeConverterUtil.stringToIntegerList(result.getAnswerGrade()));
        // 试卷相关
        resultVO.setExamTitle(exam.getExamTitle());
        resultVO.setExamGrade(exam.getExamGrade());
        resultVO.setExamTime(exam.getExamTime());
        // 题目相关
        resultVO.setChoiceList(choiceList);
        resultVO.setAnswerList(answerList);

        return resultVO;
    }
}
